﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using UnityEngine.UI;

namespace WideSliderManaged
{
    // Token: 0x02000008 RID: 8
    public class SliderModifier : MonoBehaviour
    {
        // Token: 0x06000017 RID: 23 RVA: 0x00003169 File Offset: 0x00001369
        public static void EnsureSliderModifierActivate()
        {
            if (SliderModifier._instance == null)
            {
                GameObject gameObject = new GameObject("SliderModifier");
                UnityEngine.Object.DontDestroyOnLoad(gameObject);
                SliderModifier._instance = gameObject.AddComponent<SliderModifier>();
                SliderModifier._instance.OnLevelWasLoaded(Application.loadedLevel);
            }
        }

        //// Token: 0x06000018 RID: 24 RVA: 0x000031A1 File Offset: 0x000013A1
        //private void Start()
        //{
        //}

        //// Token: 0x06000019 RID: 25 RVA: 0x000031A4 File Offset: 0x000013A4
        private void OnLevelWasLoaded(int level)
        {
            base.StopAllCoroutines();
            //CustomScene customScene = UnityEngine.Object.FindObjectOfType<CustomScene>();
            //if (customScene != null)
            //{
            //    base.StartCoroutine(this.UpdateSliderMinMax(customScene));
            //}
            //if (UnityEngine.Object.FindObjectOfType<HScene>() != null)
            //{
            //    base.StartCoroutine(this.HSceneScaleKeepCo());
            //}
        }

        //// Token: 0x0600001A RID: 26 RVA: 0x000031EE File Offset: 0x000013EE
        //private IEnumerator UpdateSliderMinMax(CustomScene customScene)
        //{
        //    List<Slider> list = new List<Slider>();
        //    SubMenuItem[] smItem = customScene.customControl.subMenuCtrl.smItem;
        //    for (int i = 0; i < smItem.Length; i++)
        //    {
        //        GameObject objTop = smItem[i].objTop;
        //        this.FindSliders(objTop.transform, list);
        //    }
        //    using (List<Slider>.Enumerator enumerator = list.GetEnumerator())
        //    {
        //        while (enumerator.MoveNext())
        //        {
        //            Slider slider = enumerator.Current;
        //            if (slider.minValue == 0f || slider.maxValue == 1f)
        //            {
        //                slider.minValue = (float)LimitConfig.NewMin / 100f;
        //                slider.maxValue = (float)LimitConfig.NewMax / 100f;
        //            }
        //        }
        //        yield break;
        //    }
        //    yield break;
        //}

        //// Token: 0x0600001B RID: 27 RVA: 0x00003204 File Offset: 0x00001404
        //private void FindSliders(Transform t, List<Slider> sliders)
        //{
        //    Slider component = t.gameObject.GetComponent<Slider>();
        //    if (component != null)
        //    {
        //        sliders.Add(component);
        //    }
        //    for (int i = 0; i < t.childCount; i++)
        //    {
        //        this.FindSliders(t.GetChild(i), sliders);
        //    }
        //}

        //// Token: 0x0600001C RID: 28 RVA: 0x0000324C File Offset: 0x0000144C
        //private bool IsApplicableSlider(Slider slider)
        //{
        //    return slider.gameObject.GetComponentInParent<SubMenuBase>() != null;
        //}

        //// Token: 0x0600001D RID: 29 RVA: 0x00003264 File Offset: 0x00001464
        //private IEnumerator HSceneScaleKeepCo()
        //{
        //    yield return new WaitForSeconds(0.1f);
        //    HScene obj = UnityEngine.Object.FindObjectOfType<HScene>();
        //    if (SliderModifier.f_charFemale != null)
        //    {
        //        CharFemale female = SliderModifier.f_charFemale.GetValue(obj) as CharFemale;
        //        this.InstallKeepScale(female);
        //    }
        //    if (SliderModifier.f_charFemales != null)
        //    {
        //        CharFemale[] array = SliderModifier.f_charFemales.GetValue(obj) as CharFemale[];
        //        if (array != null)
        //        {
        //            for (int i = 0; i < array.Length; i++)
        //            {
        //                this.InstallKeepScale(array[i]);
        //            }
        //        }
        //    }
        //    yield break;
        //}

        //// Token: 0x0600001E RID: 30 RVA: 0x00003274 File Offset: 0x00001474
        //private void InstallKeepScale(CharFemale female)
        //{
        //    if (female != null && female.chaBody != null && female.chaBody.LoadEnd)
        //    {
        //        float num = female.femaleCustomInfo.shapeValueBody[0];
        //        if (num < 0f)
        //        {
        //            float d = 0.8f - 0.2f * Mathf.Abs(num);
        //            female.chaBody.animIKCtrl.gameObject.transform.localScale = Vector3.one * d / 0.8f;
        //            return;
        //        }
        //        if (num > 1f)
        //        {
        //            float d2 = 1f + 0.2f * Mathf.Abs(num - 1f);
        //            female.chaBody.animIKCtrl.gameObject.transform.localScale = Vector3.one * d2 / 1f;
        //        }
        //    }
        //}

        // Token: 0x0400000E RID: 14
        private static SliderModifier _instance;

        //// Token: 0x0400000F RID: 15
        //private static FieldInfo f_charFemale = typeof(HScene).GetField("charFemale", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetField);

        //// Token: 0x04000010 RID: 16
        //private static FieldInfo f_charFemales = typeof(HScene).GetField("charFemales", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetField);
    }
}
